package example

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
	"github.com/jinzhu/inflection"
)

func Inflection(a fyne.App) {
	w := a.NewWindow("英语单词单复数")
	w.Resize(fyne.NewSize(900, 600))
	var result = widget.NewMultiLineEntry()
	input := widget.NewSelectEntry([]string{
		"person", "Person", "PERSON", "bus", "BUS",
		"Bus", "people", "People", "PEOPLE", "buses", "BUSES",
		"Buses", "FancyPerson", "FancyPeople"})
	msg := widget.NewLabel("")
	btn := widget.NewButton("do", func() {
		if input.Text==""{
			msg.SetText("please input a word")
			return
		}
		result.SetText(inflection.Plural(input.Text))
	})
	top := container.NewVBox(input,btn)
	c := container.NewBorder(top, msg, nil, nil, result)
	w.SetContent(c)
	w.CenterOnScreen()
	w.Show()
}
